package com.future.direction.common.util;

import com.blankj.utilcode.util.SPUtils;
import com.future.direction.common.Constant;

/**
 * 封装的SP 轻量级存储
 */

public class SharePreferencesUtils {
    /**
     * @param token 短Token
     */
    public static void saveToken(String token) {
        SPUtils.getInstance(Constant.userParts).put("token", token);
    }

    public static String getToken() {
        return SPUtils.getInstance(Constant.userParts).getString("token");
    }

    /**
     * @param fresh_token 长Token
     */
    public static void saveFreshToken(String fresh_token) {
        SPUtils.getInstance(Constant.userParts).put("fresh_token", fresh_token);
    }

    public static String getFreshToken() {
        return SPUtils.getInstance(Constant.userParts).getString("fresh_token");
    }

    /**
     * @param userId 用户ID
     */
    public static void saveUserId(String userId) {
        SPUtils.getInstance(Constant.userParts).put("userId", userId);
    }

    public static String getUserId() {
        return SPUtils.getInstance(Constant.userParts).getString("userId");
    }

    /**
     * @param userName 用户name
     */
    public static void saveUserName(String userName) {
        SPUtils.getInstance(Constant.userParts).put("userName", userName);
    }

    public static String getUserName() {
        return SPUtils.getInstance(Constant.userParts).getString("userName");
    }


    /**
     * @param account 用户账号
     */
    public static void saveAccount(String account) {
        SPUtils.getInstance(Constant.userParts).put("account", account);
    }

    public static String getAccount() {
        return SPUtils.getInstance(Constant.userParts).getString("account");
    }

    /**
     * @param password 用户密码
     */
    public static void savePassword(String password) {
        SPUtils.getInstance(Constant.userParts).put("password", password);
    }

    public static String getPassword() {
        return SPUtils.getInstance(Constant.userParts).getString("password");
    }

    /**
     * @param shopName 门店名称
     */
    public static void saveShopName(String shopName) {
        SPUtils.getInstance(Constant.userParts).put("shopName", shopName);
    }

    public static String getShopName() {
        return SPUtils.getInstance(Constant.userParts).getString("shopName");
    }

    /**
     * @param shopId 门店Id
     */
    public static void saveShopId(String shopId) {
        SPUtils.getInstance(Constant.userParts).put("shopId", shopId);
    }

    public static String getShopId() {
        return SPUtils.getInstance(Constant.userParts).getString("shopId");
    }

    /**
     * @param firstIn 首次打开app
     */
    public static void saveFirst(boolean firstIn) {
        SPUtils.getInstance(Constant.firstIn).put(Constant.firstIn, firstIn);
    }

    public static boolean isFirst() {
        return SPUtils.getInstance(Constant.firstIn).getBoolean(Constant.firstIn);
    }


    /**
     * 清除UserParts
     */
    public static void clearUserParts() {
        SPUtils.getInstance(Constant.userParts).clear();
    }


}
